// 加载FORM表单扩展
layui.use(['form'], function(){
  var form = layui.form()
  ,layer = layui.layer;

	//自定义验证规则
	form.verify({
		media: function(value){
			if(+value < 1) {
			  return '请选择媒体';
			}

			}
			,group: function(value){
			if(value.length < 1) {
			  return '请填写分组名称';
			}
		}
	});

	//监听提交
	form.on('submit(submit)', function(data){
	  $.ajax({
		  url: "/CodeGroup/create",
		  type: "post",
		  data: data.field ,
		  dataType: "json",
		  success: function (msg) {
			if(msg.status == 'success') {
				  PopModel.refreshParentFrame();
			} else {
				layer.msg(msg.msg, {icon: 5, shift: 6}, function(){});
			}
		  }
	  });
	});
	// 刷新表单
	form.render();
  
});
